﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class Objekt3DAnim
    Inherits Objekt3D
    Dim rootFrame As AnimationRootFrame
    Dim LetzterAufruf As Long

    Public Overrides Sub MeshBildLaden(ByVal Datei As String)
        'Public Sub CreateAnimation(ByVal file As String) ', ByVal presentParams As PresentParameters)


        '// Create our allocate hierarchy derived class
        Dim alloc As AllocateHierarchyDerived = New AllocateHierarchyDerived()

        '// Load our file
        rootFrame = Mesh.LoadHierarchyFromFile(Datei, MeshFlags.Managed, Grafikengine.Grafikkarte, alloc, Nothing)

        '// Calculate the center and radius of a bounding sphere
        ' objektRadius = Frame.CalculateBoundingSphere(rootFrame.FrameHierarchy, KooKomisch)

        '// Setup the matrices for animation

        SetupBoneMatrices(rootFrame.FrameHierarchy)

        '// Start the timer
        'DXUtil.Timer(DirectXTimer.Start);
        If rootFrame.AnimationController IsNot Nothing Then
            For i = 0 To rootFrame.AnimationController.NumberAnimationSets - 1
                If rootFrame.AnimationController.GetAnimationSet(i).Period = 1 Then
                    Console.WriteLine("Fehlerhafte Periode: " + Datei.Remove(0, Datei.LastIndexOf("\") + 1) + "   Animation: " + rootFrame.AnimationController.GetAnimationSet(i).Name)
                End If
            Next
        End If
    End Sub
    Public Shared Sub GenerateSkinnedMesh(ByRef Mesh As MeshContainerDerived) 'hab mal das ByVal in ByRef geändert, ansonsten sehe ich nicht, wo da der Sinn sein soll..
        If Mesh.SkinInformation Is Nothing Then
            Throw New ArgumentException()
        End If
        Dim numInfl As Integer = 0
        Dim bones As BoneCombination() = {}

        '// Use ConvertToBlendedMesh to generate a drawable mesh
        Dim m As MeshData = Mesh.MeshData
        m.Mesh = Mesh.SkinInformation.ConvertToBlendedMesh(m.Mesh, MeshFlags.Managed Or MeshFlags.OptimizeVertexCache, Mesh.GetAdjacencyStream(), numInfl, bones)

        ' // Store this info
        Mesh.numInfl = numInfl

        Mesh.SetBones(bones)

        '// Get the number of attributes
        Mesh.numAttr = bones.Length

        Mesh.MeshData = m

    End Sub
    Private Sub SetupBoneMatrices(ByVal frame As FrameDerived)

        If Not frame.MeshContainer Is Nothing Then
            SetupBoneMatrices(frame.MeshContainer)
        End If

        If Not frame.FrameSibling Is Nothing Then
            SetupBoneMatrices(frame.FrameSibling)
        End If

        If Not frame.FrameFirstChild Is Nothing Then
            SetupBoneMatrices(frame.FrameFirstChild)
        End If
    End Sub
    Private Sub SetupBoneMatrices(ByVal mesh As MeshContainerDerived)
        Dim numBones As Integer
        '    // Is there skin information?  If so, setup the matrices
        If Not mesh.SkinInformation Is Nothing Then
            numBones = mesh.SkinInformation.NumberBones
        End If
        Dim frameMatrices(numBones - 1) As FrameDerived
        For I = 0 To numBones - 1
            Dim frame As FrameDerived = Direct3D.Frame.Find(rootFrame.FrameHierarchy, mesh.SkinInformation.GetBoneName(I))

            If frame Is Nothing Then
                Throw New ArgumentException()
            End If
            frameMatrices(I) = frame
        Next

        mesh.SetFrames(frameMatrices)
    End Sub



    Public Overrides Sub Malen(ByVal worldMatrix As Matrix)
        Malen(worldMatrix, False)
    End Sub
    Public Overrides Sub Malen(ByVal worldMatrix As Microsoft.DirectX.Matrix, ByVal Einfärben As Boolean)
        DrawFrame(rootFrame.FrameHierarchy, worldMatrix)
    End Sub
    Public Function MalenAni(ByVal WorldMatrix As Matrix, ByVal AnimSetName As String, ByRef AnimSetPos As Double, Optional ByVal Einfärben As Boolean = False, Optional ByRef AnimPeriode As Double = 0)
        'Ini-Einstellungen, damit die Animation, ab der richtigen Stelle weitergemalt wird und außerdem auch überhaupt die Richtige Animation abgespielt wird.
        If rootFrame.AnimationController Is Nothing Then
            'Keine Animationen? Schade!
            DrawFrame(rootFrame.FrameHierarchy, WorldMatrix) 'dann halt nur malen und dann schnell beenden.
            Return True
        End If
        Try
            If Not rootFrame.AnimationController.GetTrackAnimationSet(0).Name = AnimSetName Then
                'Wir wollen was anderes haben... aber vielleicht gibt es das ja gar nicht?
                Dim AnimSetInd = getGültigesAnimSet(AnimSetName)
                AnimPeriode = rootFrame.AnimationController.GetAnimationSet(AnimSetInd).Period
                rootFrame.AnimationController.SetTrackAnimationSet(0, rootFrame.AnimationController.GetAnimationSet(AnimSetInd))
                rootFrame.AnimationController.SetTrackSpeed(0, 1.0#)
                rootFrame.AnimationController.SetTrackWeight(0, 1.0#)
            Else
                AnimPeriode = rootFrame.AnimationController.GetAnimationSet(AnimSetName).Period
            End If

            rootFrame.AnimationController.SetTrackPosition(0, AnimSetPos)
            If AnimPeriode = 1 Then
                '??? wirklich?
                Dim schätzung As Double = 0.00020833333333333332
                If Not (AnimSetName = "Wait" Or AnimSetName = "Attack") Then
                    Console.WriteLine("Eine Fehlerhafte Periode")
                End If
            End If

            'rootFrame.AnimationController.SetTrackEnable(0, True) 'Hmmm ist doch schon, oder? Schon immer?

            'Jetzt können wir ganz normal weitermalen...
            DrawFrame(rootFrame.FrameHierarchy, WorldMatrix, AnimPeriode)

            '...am besten geben wir zurück, wie weit wir gekommen sind, damit wir das nächstemal direkt lückenlos da weitermachen können, wo wir grade aufgehört haben.
            AnimSetPos = rootFrame.AnimationController.GetTrackDescription(0).Position

        Catch ZugriffsFehler As AccessViolationException
            Return False
        End Try

        Return True
    End Function
    Function getGültigesAnimSet(ByVal AnimSetName As String) As Integer
        'NumberAnimationSets=0 ?
        For i = 0 To rootFrame.AnimationController.NumberAnimationSets - 1
            If rootFrame.AnimationController.GetAnimationSet(i).Name.ToLower = AnimSetName.ToLower Then
                'Gefunden!
                rootFrame.AnimationController.ResetTime()
                Return i
            End If
        Next
        Return 0 'Wenn es das gesuchte nicht gibt, dann spiel eben die erst-beste Animation ab.
    End Function


    Public Sub DrawFrame(ByVal frame As FrameDerived, ByVal worldMatrix As Matrix, Optional ByVal Periode As Double = 1)
        ProcessNextFrame(worldMatrix) 'Das nächste Frame wird vorbereitet (auch Koo und so)
        If rootFrame.AnimationController IsNot Nothing Then
            If rootFrame.AnimationController.GetTrackDescription(0).Position >= Periode Then
                rootFrame.AnimationController.SetTrackPosition(0, Periode - Double.MinValue)
            End If 'nachdem die Animation einmal abgespielt wurde, ist sie vorbei!
        End If
        'und dann gemalt.
        Dim mesh As MeshContainerDerived = frame.MeshContainer
        While Not mesh Is Nothing
            DrawMeshContainer(mesh, frame)

            mesh = mesh.NextContainer
        End While

        If Not frame.FrameSibling Is Nothing Then

            DrawFrame(frame.FrameSibling, worldMatrix)
        End If

        If Not frame.FrameFirstChild Is Nothing Then
            DrawFrame(frame.FrameFirstChild, worldMatrix)
        End If
    End Sub
    Private Sub DrawMeshContainer(ByVal mesh As MeshContainerDerived, ByVal frame As FrameDerived)
        '// Is there skin information?
        If Not mesh.SkinInformation Is Nothing Then


            Dim attribIdPrev As Integer = -1

            '// Draw
            For iattrib = 0 To mesh.numAttr - 1

                Dim numBlend As Integer = 0
                Dim bones() As BoneCombination = mesh.GetBones()
                For i = 0 To mesh.numInfl - 1

                    If Not bones(iattrib).BoneId(i) = -1 Then

                        numBlend = i
                    End If
                Next

                If Grafikengine.Grafikkarte.DeviceCaps.MaxVertexBlendMatrices >= numBlend + 1 Then

                    '    // first calculate the world matrices for the current set of
                    '   // blend weights and get the accurate count of the number of
                    '  // blends
                    Dim offsetMatrices() As Matrix = mesh.GetOffsetMatrices()
                    Dim frameMatrices() As FrameDerived = mesh.GetFrames()
                    For i = 0 To mesh.numInfl - 1

                        Dim matrixIndex As Integer = bones(iattrib).BoneId(i)
                        If Not matrixIndex = -1 Then

                            Dim tempMatrix As Matrix = offsetMatrices(matrixIndex) * frameMatrices(matrixIndex).CombinedTransformationMatrix

                            Grafikengine.Grafikkarte.Transform.SetWorldMatrixByIndex(i, tempMatrix)

                        End If
                    Next

                    Grafikengine.Grafikkarte.RenderState.VertexBlend = numBlend
                    '// lookup the material used for this subset of faces
                    If Not attribIdPrev = bones(iattrib).AttributeId Or attribIdPrev = -1 Then
                        Dim M As Material = mesh.GetMaterials()(bones(iattrib).AttributeId).Material3D
                        If isSignalFarbe(M.Diffuse) Then
                            M.Emissive = M.Diffuse
                        End If
                        If My.Settings.TotalEinfärben Then
                            M.Ambient = SpielerFarbe
                            M.Diffuse = M.Ambient
                        Else
                            If M.Diffuse = Color.FromArgb(255, 18, 31, 229) Then
                                M.Ambient = SpielerFarbe
                                M.Diffuse = M.Ambient
                            End If
                        End If
                        Grafikengine.Grafikkarte.Material = M

                        Grafikengine.Grafikkarte.SetTexture(0, Objekt3D.getTextur(mesh.GetTextures()(bones(iattrib).AttributeId)))

                        attribIdPrev = bones(iattrib).AttributeId
                    Else
                        'Dim m As Material = mesh.GetMaterials()(0).Material3D
                        'm.Ambient = SpielerFarbe
                        'm.Diffuse = m.Ambient
                        'Grafikengine.Grafikkarte.Material = m
                    End If
                    'Try
                    mesh.MeshData.Mesh.DrawSubset(iattrib)
                    ' Catch
                    'End Try
                End If
            Next
        Else '// standard mesh, just draw it after setting material properties

            Grafikengine.Grafikkarte.Transform.World = frame.CombinedTransformationMatrix

            Dim mtrl() As ExtendedMaterial = mesh.GetMaterials()
            For iMaterial = 0 To mtrl.Length - 1
                Dim M As Material = mtrl(iMaterial).Material3D
                If isSignalFarbe(M.Diffuse) Then
                    M.Emissive = M.Diffuse
                End If
                If My.Settings.TotalEinfärben Then
                    'My.Settings.TotalEinfärben = True
                    'My.Settings.Save()
                    M.Ambient = SpielerFarbe
                    M.Diffuse = M.Ambient
                Else
                    If M.Diffuse = Color.FromArgb(255, 18, 31, 229) Then
                        M.Ambient = SpielerFarbe
                        M.Diffuse = M.Ambient
                    End If
                End If
                Grafikengine.Grafikkarte.Material = M
                Grafikengine.Grafikkarte.SetTexture(0, Objekt3D.getTextur(mesh.GetTextures()(iMaterial)))
                mesh.MeshData.Mesh.DrawSubset(iMaterial)
            Next
        End If
    End Sub

    Private Sub ProcessNextFrame(ByVal worldMatrix As Matrix)
        ' // Set the world matrix
        'Dim worldMatrix As Matrix = Matrix.RotationY(Rotation)
        'worldMatrix.M41 = Objekt3D.Feldbreite * Koo.X
        'worldMatrix.M42 = 0
        'worldMatrix.M43 = Koo.Z * Objekt3D.Feldbreite
        '' worldMatrix = Matrix.Translation(New Vector3(14, 0, 14))
        Grafikengine.Grafikkarte.Transform.World = worldMatrix

        If Not rootFrame.AnimationController Is Nothing Then
            'Anz += 1
            'If Anz > 50000 Then
            '    '    rootFrame.AnimationController.SetTrackPosition(0, 0)
            '    Anz = 0
            'End If
            ' Dim s As String = rootFrame.AnimationController.GetTrackAnimationSet(0).GetAnimationName(1)
            'Dim posAnim As Double = rootFrame.AnimationController.GetTrackDescription(0).Position
            'Dim Periode As Double = rootFrame.AnimationController.GetAnimationSet(0).Period
            'If posAnim > rootFrame.AnimationController.GetAnimationSet(0).Period Then
            'rootFrame.AnimationController.SetTrackPosition(0, 0.3)
            'End If

            ' Dim ASet As AnimationSet = rootFrame.AnimationController.GetAnimationSet(0)

            ' Dim d As Double = ASet.GetPeriodicPosition(rootFrame.AnimationController.Time)
            'If d >= 1 Then
            '    rootFrame.AnimationController.SetTrackPosition(0, 0)
            'End If
            'posAnim = rootFrame.AnimationController.GetTrackDescription(0).Position



            'MIT KORREKTER ZEIT: |----------------------------------------------------------------------------->

            'Dim Aufruf As Long = Now.Ticks
            'Dim Tiks As Long = (Aufruf - LetzterAufruf)
            'Dim TpS As Long = My.Settings.AnimGeschw3D * TimeSpan.TicksPerSecond * 70
            'If Tiks > 5 * TpS Then Tiks = TpS * 5
            'Dim vZ As Double = Tiks / TpS
            'rootFrame.AnimationController.AdvanceTime(vZ, Nothing)
            'Dim AniAnz As Integer = rootFrame.AnimationController.MaxNumberTracks
            'LetzterAufruf = Aufruf

            '----------------------------------------------------------------------------->| MIT KORREKTER ZEIT

            'Mit absoluter Zeit: (Animationen werden langsamer, wenn FPS sinkt!
            rootFrame.AnimationController.AdvanceTime(0.00001, Nothing)





            ' rootFrame.AnimationController.SetTrackEnable(0, False)
            'Dim t0 As TrackDescription = rootFrame.AnimationController.GetTrackDescription(0)
            'Dim t1 As TrackDescription = rootFrame.AnimationController.GetTrackDescription(1)

            'Dim Anis As Integer = rootFrame.AnimationController.GetTrackAnimationSet(0).NumberAnimations
            'Dim Aniname As String = rootFrame.AnimationController.GetAnimationSet(0).Name
            'Anis = rootFrame.AnimationController.GetAnimationSet(0).NumberAnimations
            'Dim ASetNeu As AnimationSet = rootFrame.AnimationController.GetAnimationSet(1)
            'Dim ASetAlt As AnimationSet = rootFrame.AnimationController.GetAnimationSet(0)

            'rootFrame.AnimationController.SetTrackAnimationSet(0, ASetNeu)
            'rootFrame.AnimationController.UnkeyAllTrackEvents(0)
            'rootFrame.AnimationController.KeyTrackEnable(0, True, 0)
            'rootFrame.AnimationController.KeyTrackSpeed(0, 1.0#, 0, 0, TransitionType.Linear)
            'rootFrame.AnimationController.KeyTrackWeight(0, 1.0#, 0, 0, TransitionType.Linear)

            'rootFrame.AnimationController.SetTrackAnimationSet(0, ASetNeu)
            ''rootFrame.AnimationController.UnkeyAllTrackEvents(0)
            'rootFrame.AnimationController.SetTrackSpeed(0, 1.0#)
            'rootFrame.AnimationController.SetTrackWeight(0, 0.7#)
            'rootFrame.AnimationController.SetTrackWeight(1, 0.3#)
            'rootFrame.AnimationController.SetTrackEnable(0, True)
            ' rootFrame.AnimationController.
            'rootFrame.AnimationController.SetTrackEnable(0, True)
            ' rootFrame.AnimationController.SetTrackEnable(0, False)
            ' t1.Enable = t0.Enable

            't1.Speed = t0.Speed
            ' t1.Weight = t0.Weight
            't0.Weight = 0
            ' Dim TDis As TrackDescription = rootFrame.AnimationController.GetTrackDescription(1)
            'TDis.Enable = True
            'TDis.Speed = 1
            'TDis.Priority = PriorityType.Low
            'TDis.Weight = 1
            'TDis.Position = 0

            ' rootFrame.AnimationController.SetTrackEnable(1, True)
            '  Dim i As Integer = rootFrame.AnimationController.NumberAnimationSets
            ' Dim aniname As String = rootFrame.AnimationController.GetTrackAnimationSet(0).GetAnimationName(0)

            ' i.ToString()

            '            rootFrame.AnimationController.SetTrackPosition(0, Math.Floor(Position)) 'Ich runde immer ab, da ansonsten was ganz komisches Passiert, da er die Dezimalzahlen irgendwie falsch auffasst.
            'Dim i As Integer = rootFrame.AnimationController.MaxNumberTracks
            'Console.WriteLine("Vergangene Zeit: " + rootFrame.AnimationController.Time.ToString)
            'TimeDelta as Double:
            'Amount, in seconds, by which to advance the global animation time. This value must be non-negative or 0.

            'vergangeneZeitGesamt += vergangeneZeit
            'vergangeneZeit = 0
            'While vergangeneZeitGesamt >= Periodendauer
            '    vergangeneZeitGesamt -= Periodendauer
            'End While
        End If
        UpdateFrameMatrices(rootFrame.FrameHierarchy, worldMatrix)
    End Sub
    Private Sub UpdateFrameMatrices(ByVal frame As FrameDerived, ByVal parentMatrix As Matrix)
        frame.CombinedTransformationMatrix = frame.TransformationMatrix * parentMatrix

        If Not frame.FrameSibling Is Nothing Then
            UpdateFrameMatrices(frame.FrameSibling, parentMatrix)
        End If

        If Not frame.FrameFirstChild Is Nothing Then
            UpdateFrameMatrices(frame.FrameFirstChild, frame.CombinedTransformationMatrix)
        End If
    End Sub
End Class
'MeshBildladen:

'Dim pfad As String = Datei
'Dim pfadTextures As String = My.Settings.Resourcenpfad + "Landschaften\Bilder\3D\" + My.Settings.TexturQuali + "\"

'Dim mtrlBuffer() As ExtendedMaterial = {}
'MeshBild = New strMeshBild
'With MeshBild
'    .moName = Datei.Remove(0, Datei.LastIndexOf("\") + 1).Replace(".x", "")
'    .moMesh = Microsoft.DirectX.Direct3D.Mesh.FromFile(Datei, MeshFlags.Managed, Grafikengine.Grafikkarte, mtrlBuffer)
'    .mlMeshMaterials = mtrlBuffer.Length
'    ReDim .moMaterials(.mlMeshMaterials - 1)
'    ReDim .moTextures(.mlMeshMaterials - 1)
'    'Jetzt weren die Texturen und Materialien geladen.
'    Dim X As Integer
'    Dim sTemp As String
'    For X = 0 To mtrlBuffer.Length - 1
'        .moMaterials(X) = mtrlBuffer(X).Material3D
'        .moMaterials(X).Ambient = .moMaterials(X).Diffuse 'because directx sometimes doesnt do this for you
'        If Not mtrlBuffer(X).TextureFilename = "" Then
'            sTemp = pfadTextures & mtrlBuffer(X).TextureFilename
'            .moTextures(X) = TextureLoader.FromFile(Grafikengine.Grafikkarte, sTemp)  'Stopp mit den Bildern gibt es noch irgendwelche Probleme!
'        End If
'    Next
'End With


'Malen

'Grafikengine.Grafikkarte.RenderState.Lighting = True
'With MeshBild
'    For X = 0 To .mlMeshMaterials - 1
'        Dim M As Material = .moMaterials(X)
'        'My.Settings.TotalEinfärben = False
'        ' My.Settings.Save()
'        If My.Settings.TotalEinfärben Then
'            M.Ambient = SpielerFarbe
'            M.Diffuse = M.Ambient
'        Else
'            If .moTextures(X) Is Nothing Then
'                If M.Ambient = Color.FromArgb(255, 18, 31, 229) Then
'                    M.Ambient = SpielerFarbe
'                    M.Diffuse = M.Ambient
'                End If
'            End If
'        End If
'        Grafikengine.Grafikkarte.Material = M
'        'Grafikengine.Grafikkarte.Material = .moMaterials(X)
'        Grafikengine.Grafikkarte.SetTexture(0, .moTextures(X))
'        .moMesh.DrawSubset(X)
'    Next X
'End With
'Grafikengine.Grafikkarte.RenderState.Lighting = False




Public Class AllocateHierarchyDerived
    Inherits AllocateHierarchy


    Public Overrides Function CreateFrame(ByVal name As String) As Microsoft.DirectX.Direct3D.Frame
        Dim frame As FrameDerived = New FrameDerived()
        frame.Name = name
        frame.TransformationMatrix = Matrix.Identity
        frame.CombinedTransformationMatrix = Matrix.Identity

        Return frame
    End Function

    Public Overrides Function CreateMeshContainer(ByVal name As String, ByVal meshData As Microsoft.DirectX.Direct3D.MeshData, ByVal materials() As Microsoft.DirectX.Direct3D.ExtendedMaterial, ByVal effectInstances() As Microsoft.DirectX.Direct3D.EffectInstance, ByVal adjacency As Microsoft.DirectX.GraphicsStream, ByVal skinInfo As Microsoft.DirectX.Direct3D.SkinInformation) As Microsoft.DirectX.Direct3D.MeshContainer
        ' Dim pfadTextures As String = My.Settings.Resourcenpfad + "Landschaften\Bilder\3D\" + My.Settings.TexturQuali + "\"
        '// We only handle meshes here
        If meshData.Mesh Is Nothing Then
            Throw New ArgumentException()
        End If
        ' // We must have a vertex format mesh
        If meshData.Mesh.VertexFormat = VertexFormats.None Then
            Throw New ArgumentException()
        End If
        Dim mesh As MeshContainerDerived = New MeshContainerDerived()

        mesh.Name = name
        Dim numFaces As Integer = meshData.Mesh.NumberFaces
        Dim dev As Device = meshData.Mesh.Device

        ' // Make sure there are normals
        If (meshData.Mesh.VertexFormat & VertexFormats.Normal) = 0 Then

            '// Clone the mesh
            Dim tempMesh As Mesh = meshData.Mesh.Clone(meshData.Mesh.Options.Value, meshData.Mesh.VertexFormat Or VertexFormats.Normal, dev)

            meshData.Mesh = tempMesh
            meshData.Mesh.ComputeNormals()
        End If

        '// Store the materials
        mesh.SetMaterials(materials)
        mesh.SetAdjacency(adjacency)
        Dim meshTextures(materials.Length - 1) As String
        '------------- hier kommt ursprünglich das "versetzt" von unten rein.
        mesh.MeshData = meshData 'War ursprünglich nach mesh.SetTextures(meshTextures) ganz unten. (Das heißt das unten war eigentlich über mir.)

        ' // If there is skinning info, save any required data
        If Not skinInfo Is Nothing Then

            mesh.SkinInformation = skinInfo
            Dim numBones As Integer = skinInfo.NumberBones
            Dim offsetMatrices(numBones - 1) As Matrix
            For I = 0 To numBones - 1
                offsetMatrices(I) = skinInfo.GetBoneOffsetMatrix(I)
            Next
            mesh.SetOffsetMatrices(offsetMatrices)

            Objekt3DAnim.GenerateSkinnedMesh(mesh)
        End If

       
        '----------------------------- versetzt --------------------------
        ' // Create any textures
        For I = 0 To materials.Length - 1

            If Not materials(I).TextureFilename Is Nothing Then
                Objekt3D.TexturLaden(materials(I).TextureFilename)
                meshTextures(I) = materials(I).TextureFilename
            End If
        Next
        mesh.SetTextures(meshTextures)
        '----------------------------- versetzt --------------------------
        Return mesh

    End Function


End Class


Public Class FrameDerived
    Inherits Frame


    Private Combined As Matrix = Matrix.Identity
    Public Property CombinedTransformationMatrix() As Matrix
        Get
            Return Combined
        End Get
        Set(ByVal value As Matrix)
            Combined = value
        End Set
    End Property

End Class


Public Class MeshContainerDerived
    Inherits MeshContainer
    Private meshTextures As String() = Nothing
    Public numAttr As Integer = 0
    Public numInfl As Integer = 0
    Private bones() As BoneCombination
    Private frameMatrices() As FrameDerived
    Private offsetMatrices() As Matrix

    '// Public properties
    Public Function GetTextures() As String()
        Return meshTextures
    End Function
    Public Sub SetTextures(ByVal Textures() As String)
        meshTextures = Textures
    End Sub

    Public Function GetBones() As BoneCombination()
        Return bones
    End Function
    Public Sub SetBones(ByVal b() As BoneCombination)
        bones = b
    End Sub

    Public Function GetFrames() As FrameDerived()
        Return frameMatrices
    End Function
    Public Sub SetFrames(ByVal frames() As FrameDerived)
        frameMatrices = frames
    End Sub

    Public Function GetOffsetMatrices() As Matrix()
        Return offsetMatrices
    End Function
    Public Sub SetOffsetMatrices(ByVal matrices() As Matrix)
        offsetMatrices = matrices
    End Sub





End Class